<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>商品管理</title>
<script src="../js/jquery1.9.1.js" type="text/javascript"></script>
<script src="../js/jquery.pager.js" type="text/javascript"></script>
<script src="../js/iframeAuto.js" type="text/javascript"></script>
<link href="../js/Pager.css" rel="stylesheet" type="text/css" />
<link href="../styles/edas_back.css" rel="stylesheet" type="text/css"/>
</head>
<body>
	<div id="mainContainer" style="Margin-Right: auto; Margin-Left: auto;"
		align="left">

		<table id="data_table_id" class="didiao">
			<tr id="title_id">
				<td width="220px"  style=" border-top:0px;">最后更新时间</td>
				<td width="120px"  style=" border-top:0px;">标题</td>
				<td width="120px"  style=" border-top:0px;">封面图</td>
				<td width="120px"  style=" border-top:0px;">操作</td>
			</tr>
			<tr id="start_id">
			</tr>
		</table>

		<br> <br> <br>
		<div id="pager"></div>
		
		<table id="table_model_id" style="display: none">
				<tr id="tr_model_id">
					<td width="120px"  id="room_start_time"></td>
					<td width="120px" id="per_name_id"></td>
					<td width="120px" ><img id="pic_id" width="60" height="60"/></td>
					<td width="180px" >
						<a id="edit_id" href="#" title="查看子图片">查看子图片</a>
						<a id="edit_id" href="#" title="编辑"><img border="0px" src="../images/btn_edit.png"/></a>
						<a id="del_id" href="#" title="删除"><img  border="0px" src="../images/btn_delete.png"/></a>
					</td>
				</tr>
		</table>

	</div>
	
	<script>
		$(function(){
			init(1);
		});
		//默认加载  
		function init(pagenumber) {
			jQuery.ajax({
				type : 'Get',
				contentType : 'application/json',
				url : '../goods/pageList.do',
				data : {
					currPage : pagenumber
				},
				dataType : 'json',
				success : function(data) {
					if (data.result) {
						$("#pager").pager({
							pagenumber : pagenumber,
							pagecount : data.obj.totalPage,
							buttonClickCallback : PageClick
						});
						
						//删除表格原先数据
						$('#data_table_id tr').each(
							function(){
								if($(this).attr("id") != "start_id" && $(this).attr("id") != "title_id"){
									$(this).remove();		
								}
							}
						);
						
						try{
							//为表格设置数据
							var goodsList = data.obj.goodsList;
							for(var i in goodsList){
								var htm1 = $('#tr_model_id').html();
				          		var newTr1 = "<tr>"+htm1+"</tr>";
				          		var newTr1Obj = $('#start_id').before(newTr1).prev();
				          			newTr1Obj.find("#room_start_time").html(goodsList[i].updateDate);
				          			newTr1Obj.find("#per_name_id").html(goodsList[i].goods.title);
				          			newTr1Obj.find("#pic_id").attr("src","../upload/downloadCompress.do?fileName="+goodsList[i].goods.picName);
				          		}
							
						}catch(e){
							alert(e);
						}
						//调整iframe高度
						autoIframe();
					} else {
							alert(data.errorMsg);
					}
				},
				error : function(data) {
					alert("error");
				}
			});
		}

		//回调函数  
		PageClick = function(pageclickednumber) {
			init(pageclickednumber);
		}
	</script>
		
</body>
</html>